package com.retirement.policy.controller;


import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import com.retirement.policy.domain.dto.PropertyPolicyAddDto;
import com.retirement.policy.domain.dto.PropertyPolicyDto;
import com.retirement.policy.domain.dto.PropertyPolicyUpdateDto;
import com.retirement.policy.service.IPropertyPolicyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2024-01-16
 */
@Api(value = "政策管理", tags = "政策管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/policy")
public class PropertyPolicyController extends BaseController {

    @Resource
    private IPropertyPolicyService iPropertyPolicyService;

    @GetMapping("/page")
    @ApiOperation("分页获取政策")
    public TableDataInfo addPolicy(PropertyPolicyDto dto){
        startPage();
        return getDataTable(iPropertyPolicyService.getListPolicy(dto));
    }

    @PostMapping
    @ApiOperation("新增政策")
    private AjaxResult addPolicy(PropertyPolicyAddDto dto){
        return AjaxResult.success(iPropertyPolicyService.addPolicy(dto));
    }

    @PutMapping
    @ApiOperation("修改政策信息")
    public AjaxResult updatePolicy(PropertyPolicyUpdateDto dto){
        return AjaxResult.success(iPropertyPolicyService.updatePolicy(dto));
    }

    @GetMapping
    @ApiOperation("相关文件")
    public String relevantDocuments(PropertyPolicyDto dto){
        return iPropertyPolicyService.relevantDocuments(dto);
    }

}
